package com.xsd.awen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xsd.awen.domain.entity.Project;
import com.xsd.awen.domain.po.ProjectPagePo;
import com.xsd.awen.domain.vo.ProjectVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProjectMapper extends BaseMapper<Project> {

    @Select("<script> " +
            " select u.* from t_tk_project u " +
            " where 1=1 " +
            "<if test=\"project.name != null and project.name != ''\"> and u.name like CONCAT('%', #{project.name}, '%')</if>" +
            " order by u.create_time desc " +
            "</script>")
    List<ProjectPagePo> page(ProjectVo projectVo);

    @Select(" select count(1) from t_tk_project where name = #{name} ")
    Integer countProject(Project project);

    @Select(" select count(1) from t_tk_project where name = #{name} and id != #{id} ")
    Integer countUpdateProject(Project project);

}